home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sun4c.md / machMon.h < prev    next >
C/C++ Source or Header  |  1990-10-19  |  7KB  |  231 lines

  1. /*
  2.  * machMon.h --
  3.  *
  4.  *     Structures, constants and defines for access to the sun monitor.
  5.  *     These are translated from the sun monitor header file "openprom.h".
  6.  *
  7.  * Copyright (C) 1985 Regents of the University of California
  8.  * All rights reserved.
  9.  *
  10.  *
  11.  * $Header: /sprite/src/kernel/mach/sun4c.md/RCS/machMon.h,v 1.4 90/10/19 15:38:39 mgbaker Exp $ SPRITE (Berkeley)
  12.  */
  13.  
  14. #ifndef _MACHMON
  15. #define _MACHMON
  16.  
  17. /*
  18.  * The memory addresses for the PROM, and the EEPROM.
  19.  */
  20. #define EEPROM_BASE     0xffd04000
  21. #define PROM_BASE       0xffe80010
  22.  
  23. /*
  24.  * The table entry that describes a device.  It exists in the PROM; a
  25.  * pointer to it is passed in MachMonBootParam.  It can be used to locate
  26.  * PROM subroutines for opening, reading, and writing the device.
  27.  *
  28.  * When using this interface, only one device can be open at once.
  29.  *
  30.  * NOTE: I am not sure what arguments boot, open, close, and strategy take.
  31.  * What is here is just translated verbatim from the sun monitor code.  We
  32.  * should figure this out eventually if we need it.
  33.  */
  34.  
  35. typedef struct {
  36.     char    devName[2];        /* The name of the device */
  37.     int    (*probe)();        /* probe() --> -1 or found controller
  38.                        number */
  39.     int    (*boot)();        /* boot(bp) --> -1 or start address */
  40.     int    (*open)();        /* open(iobp) --> -1 or 0 */
  41.     int    (*close)();        /* close(iobp) --> -1 or 0 */
  42.     int    (*strategy)();        /* strategy(iobp,rw) --> -1 or 0 */
  43.     char    *desc;            /* Printable string describing dev */
  44.     /* Sun4 has struct devinfo here.  Do I need it? */
  45. } MachMonBootTable;
  46.  
  47. /*
  48.  * Structure set up by the boot command to pass arguments to the program that
  49.  * is booted.
  50.  */
  51.  
  52. typedef struct {
  53.     char        *argPtr[8];    /* String arguments */
  54.     char        strings[100];    /* String table for string arguments */
  55.     char        devName[2];    /* Device name */
  56.     int        ctlrNum;    /* Controller number */
  57.     int        unitNum;    /* Unit number */
  58.     int        partNum;    /* Partition/file number */
  59.     char        *fileName;    /* File name, points into strings */
  60.     MachMonBootTable   *bootTable;    /* Points to table entry for device */
  61. } MachMonBootParam;
  62.  
  63. /*
  64.  * Memory layout stuff for the sun4c prom.
  65.  */
  66. typedef    struct    Mach_MemList {
  67.     struct        Mach_MemList    *next;
  68.     unsigned int    address;
  69.     unsigned int    size;
  70. } Mach_MemList;
  71.  
  72. struct    config_ops {
  73.         int (*devr_next)(/* int nodeid */);
  74.         int (*devr_child)(/* int nodeid */);
  75.         int (*devr_getproplen)(/* int nodeid; caddr_t name; */);
  76.         int (*devr_getprop)(/* int nodeid; caddr_t name; addr_t value; */);
  77.         int (*devr_setprop)(/* int nodeid; caddr_t name; addr_t value; int len;
  78. */);
  79.         int (*devr_nextprop)(/* int nodeid; caddr_t previous; */);
  80. };
  81.  
  82. /*
  83.  * Here is the structure of the vector table which is at the front of the boot
  84.  * rom.  The functions defined in here are explained below.
  85.  */
  86.  
  87. typedef struct {
  88.     unsigned int    v_magic;      /* magic mushroom */
  89.     unsigned int          v_romvec_version; /* Version number of "romvec" */
  90.     unsigned int    v_plugin_version; /* Plugin Architecture version */
  91.     unsigned int    monId;          /* version # of monitor firmware */
  92.     Mach_MemList    **physMemory;      /* total physical memory list */
  93.     Mach_MemList    **virtMemory;      /* taken virtual memory list */
  94.     Mach_MemList    **availMemory;    /* available physical memory */
  95.     struct config_ops    *v_config_ops;      /* dev_info configuration access */
  96.     /*
  97.      * storage device access facilities
  98.      */
  99.     char        **v_bootcommand;  /* expanded with PROM defaults */
  100.     unsigned int    (*v_open)(/* char *name */);
  101.     unsigned int    (*v_close)(/* unsigned int fileid */); 
  102.     /*
  103.      * block-oriented device access
  104.      */
  105.     unsigned int    (*v_read_blocks)();
  106.     unsigned int    (*v_write_blocks)();
  107.     /*
  108.      * network device access
  109.      */
  110.     unsigned int    (*v_xmit_packet)();
  111.     unsigned int    (*v_poll_packet)();
  112.     /*
  113.      * byte-oriented device access
  114.      */
  115.     unsigned int    (*v_read_bytes)();
  116.     unsigned int    (*v_write_bytes)();
  117.  
  118.     /*
  119.      * 'File' access - i.e.,  Tapes for byte devices.  TFTP for network devices
  120.      */
  121.     unsigned int     (*v_seek)();
  122.     /*
  123.      * single character I/O
  124.      */
  125.     unsigned char    *inSource;       /* Current source of input */
  126.     unsigned char    *outSink;        /* Currrent output sink */
  127.     unsigned char    (*getChar)();    /* Get a character from input */ 
  128.     void        (*putChar)();    /* Put a character to output sink. */
  129.     int            (*mayGet)();     /* Maybe get a character, or "-1". */
  130.     int            (*mayPut)();     /* Maybe put a character, or "-1". */
  131.     /* 
  132.      * Frame buffer
  133.      */
  134.     void        (*fbWriteStr)();  /* write a string to framebuffer */
  135.     /*
  136.      * Miscellaneous Goodies
  137.      */
  138.     void        (*reBoot)();       /* reboot machine */
  139.     int            (*printf)();       /* handles fmt string plus 5 args */
  140.     void        (*abortEntry)();   /* Entry for keyboard abort. */
  141.     int         *nmiClock;       /* Counts in milliseconds. */
  142.     void        (*exitToMon)();/* Exit from user program. */
  143.     void        (**v_vector_cmd)();/* Handler for the vector */
  144.     void        (*v_interpret)();  /* interpret forth string */
  145.  
  146. /*
  147.  *  This may actually be old boot params, depending on this #define:
  148.  *  #ifdef SAIO_COMPAT
  149.  *  MachMonBootParam    **bootParam;
  150.  *             boot parameters and `old' style device access
  151.  *  Otherwise, it's just an int-size padding.
  152.  *  int            pad;
  153.  */
  154.     MachMonBootParam    **bootParam;
  155.  
  156.     unsigned int    (*v_mac_address)(/* int fd; caddr_t buf */);
  157.                         /* Copyout ether address */
  158.     int            *v_reserved[31];
  159.     /*
  160.      * Beginning of machine-dependent portion.
  161.      */
  162.     void        (*SetSegInContext)();    /* set seg map in another
  163.                          * context without worrying
  164.                          * about whether it's mapped. */
  165. } MachMonRomVector;
  166.  
  167. /*
  168.  * Functions defined in the vector:
  169.  *
  170.  *
  171.  * getChar -- Return the next character from the input source
  172.  *
  173.  *     unsigned char getChar()
  174.  *
  175.  * putChar -- Write the given character to the output source.
  176.  *
  177.  *     void putChar(ch)
  178.  *       char ch;
  179.  *
  180.  * mayGet -- Maybe get a character from the current input source.  Return -1
  181.  *           if don't return a character.
  182.  *
  183.  *     int mayGet()
  184.  *
  185.  * mayPut -- Maybe put a character to the current output source.   Return -1
  186.  *           if no character output.
  187.  *
  188.  *    int  mayPut(ch)
  189.  *        char ch;
  190.  *
  191.  * fbWriteStr -- Write a string to the frame buffer.
  192.  *
  193.  *       void fwritestr(addr,len)
  194.  *          register unsigned char *addr;    / * String to be written * /
  195.  *          register short len;            / * Length of string * /
  196.  *
  197.  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
  198.  *          are recognized.
  199.  *
  200.  * abortEntry -- Entry for keyboard abort.
  201.  *
  202.  *     void abortEntry()
  203.  *
  204.  * SetSegInContext(c, v, p)
  205.  *    context        c;
  206.  *    virtual addr    v;
  207.  *    pmeg_num    p;
  208.  */
  209.  
  210. /*
  211.  * For accessing the romVector.
  212.  */
  213. #define    romVectorPtr    ((MachMonRomVector *) PROM_BASE)
  214.  
  215. /*
  216.  * Functions and defines to access the monitor.
  217.  */
  218.  
  219. #define Mach_MonPrintf (romVectorPtr->printf)
  220. #define Mach_MonGetChar (romVectorPtr->getChar)
  221.  
  222. extern    void     Mach_MonPutChar _ARGS_((int ch));
  223. extern    int      Mach_MonMayPut _ARGS_((int ch));
  224. extern    void    Mach_MonAbort _ARGS_((void));
  225. extern    void    Mach_MonReboot _ARGS_((char *rebootString));
  226. extern  void    Mach_MonTrap _ARGS_((Address address_to_trap_to));
  227. extern    void    Mach_MonStopNmi _ARGS_((void));
  228. extern    void    Mach_MonStartNmi _ARGS_((void));
  229.  
  230. #endif /* _MACHMON */
  231.